﻿@model OrderSettingsModel

@{
    //page title
    ViewBag.Title = T("Admin.Configuration.Settings.Order").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Order settings");
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="content-header clearfix">
        <h1 class="pull-left">
            @T("Admin.Configuration.Settings.Order")
        </h1>
        <div class="pull-right">
            <button type="submit" name="save" class="btn bg-blue">
                <i class="fa fa-floppy-o"></i>
                @T("Admin.Common.Save")
            </button>
        </div>
    </div>

    <script>
        $(document).ready(function() {
            bindBootstrapTabSelectEvent('ordersettings-edit');
        });
    </script>

    <div class="content">
        <div class="form-horizontal">
            @Html.Action("ProjectScopeConfiguration", "Setting")
            @Html.Action("Mode", "Setting")
            @Html.ValidationSummary(false)

            <div id="ordersettings-edit" class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                    @Html.RenderBootstrapTabHeader("tab-info", @T("Admin.Configuration.Settings.Order.OrderSettings"), true)
                    @Html.RenderBootstrapTabHeader("tab-returnrequest", @T("Admin.Configuration.Settings.Order.ReturnRequestSettings"))
                </ul>
                <div class="tab-content">
                    @Html.RenderBootstrapTabContent("tab-info", @TabOrderSettings(), true)
                    @Html.RenderBootstrapTabContent("tab-returnrequest", @TabReturnRequestSettings())
                </div>
            </div>
        </div>
    </div>

    {
        //custom tabs
        var eventMessage = new AdminTabStripCreated(this.Html, "ordersettings-edit");
        EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
        foreach (var eventBlock in eventMessage.BlocksToRender)
        {
            @eventBlock
        }
    }

    @*save selected tab name*@
    <input type="hidden" id="selected-tab-name" name="selected-tab-name" value="@(Html.GetSelectedTabName())">
}

@helper TabOrderSettings()
{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#@Html.FieldIdFor(model => model.OnePageCheckoutEnabled)").click(toggleOnePageCheckoutEnabled);
            toggleOnePageCheckoutEnabled();
        });

        function toggleOnePageCheckoutEnabled() {
            if ($('#@Html.FieldIdFor(model => model.OnePageCheckoutEnabled)').is(':checked')) {
                $('#pnlOnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab').show();
            }
            else {
                $('#pnlOnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab').hide();
            }
        }
    </script>

    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.AnonymousCheckoutAllowed_OverrideForProject, model => model.AnonymousCheckoutAllowed, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.AnonymousCheckoutAllowed)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.AnonymousCheckoutAllowed)
                        @Html.ValidationMessageFor(model => model.AnonymousCheckoutAllowed)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.OnePageCheckoutEnabled_OverrideForProject, model => model.OnePageCheckoutEnabled, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.OnePageCheckoutEnabled)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.OnePageCheckoutEnabled)
                        @Html.ValidationMessageFor(model => model.OnePageCheckoutEnabled)
                    </div>
                </div>
                <div class="form-group advanced-setting" id="pnlOnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.OnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab_OverrideForProject, model => model.OnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.OnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.OnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab)
                        @Html.ValidationMessageFor(model => model.OnePageCheckoutDisplayOrderTotalsOnPaymentInfoTab)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.TermsOfServiceOnShoppingCartPage_OverrideForProject, model => model.TermsOfServiceOnShoppingCartPage, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.TermsOfServiceOnShoppingCartPage)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.TermsOfServiceOnShoppingCartPage)
                        @Html.ValidationMessageFor(model => model.TermsOfServiceOnShoppingCartPage)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.TermsOfServiceOnOrderConfirmPage_OverrideForProject, model => model.TermsOfServiceOnOrderConfirmPage, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.TermsOfServiceOnOrderConfirmPage)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.TermsOfServiceOnOrderConfirmPage)
                        @Html.ValidationMessageFor(model => model.TermsOfServiceOnOrderConfirmPage)
                    </div>
                </div>
                @if (Model.OrderIdent.HasValue)
                {
                    <div class="form-group advanced-setting">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.OrderIdent)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.OrderIdent)
                        </div>
                    </div>
                }
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.IsReOrderAllowed_OverrideForProject, model => model.IsReOrderAllowed, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.IsReOrderAllowed)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.IsReOrderAllowed)
                        @Html.ValidationMessageFor(model => model.IsReOrderAllowed)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.MinOrderSubtotalAmount_OverrideForProject, model => model.MinOrderSubtotalAmount, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.MinOrderSubtotalAmount)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.MinOrderSubtotalAmount)
                        @Html.ValidationMessageFor(model => model.MinOrderSubtotalAmount) @Model.PrimaryProjectCurrencyCode
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.MinOrderSubtotalAmountIncludingTax_OverrideForProject, model => model.MinOrderSubtotalAmountIncludingTax, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.MinOrderSubtotalAmountIncludingTax)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.MinOrderSubtotalAmountIncludingTax)
                        @Html.ValidationMessageFor(model => model.MinOrderSubtotalAmountIncludingTax)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.MinOrderTotalAmount_OverrideForProject, model => model.MinOrderTotalAmount, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.MinOrderTotalAmount)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.MinOrderTotalAmount)
                        @Html.ValidationMessageFor(model => model.MinOrderTotalAmount) @Model.PrimaryProjectCurrencyCode
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.AutoUpdateOrderTotalsOnEditingOrder_OverrideForProject, model => model.AutoUpdateOrderTotalsOnEditingOrder, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.AutoUpdateOrderTotalsOnEditingOrder)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.AutoUpdateOrderTotalsOnEditingOrder)
                        @Html.ValidationMessageFor(model => model.AutoUpdateOrderTotalsOnEditingOrder)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.DisableBillingAddressCheckoutStep_OverrideForProject, model => model.DisableBillingAddressCheckoutStep, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.DisableBillingAddressCheckoutStep)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.DisableBillingAddressCheckoutStep)
                        @Html.ValidationMessageFor(model => model.DisableBillingAddressCheckoutStep)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.DisableOrderCompletedPage_OverrideForProject, model => model.DisableOrderCompletedPage, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.DisableOrderCompletedPage)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.DisableOrderCompletedPage)
                        @Html.ValidationMessageFor(model => model.DisableOrderCompletedPage)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.AttachPdfInvoiceToOrderPlacedEmail_OverrideForProject, model => model.AttachPdfInvoiceToOrderPlacedEmail, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.AttachPdfInvoiceToOrderPlacedEmail)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.AttachPdfInvoiceToOrderPlacedEmail)
                        @Html.ValidationMessageFor(model => model.AttachPdfInvoiceToOrderPlacedEmail)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.AttachPdfInvoiceToOrderPaidEmail_OverrideForProject, model => model.AttachPdfInvoiceToOrderPaidEmail, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.AttachPdfInvoiceToOrderPaidEmail)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.AttachPdfInvoiceToOrderPaidEmail)
                        @Html.ValidationMessageFor(model => model.AttachPdfInvoiceToOrderPaidEmail)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.AttachPdfInvoiceToOrderCompletedEmail_OverrideForProject, model => model.AttachPdfInvoiceToOrderCompletedEmail, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.AttachPdfInvoiceToOrderCompletedEmail)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.AttachPdfInvoiceToOrderCompletedEmail)
                        @Html.ValidationMessageFor(model => model.AttachPdfInvoiceToOrderCompletedEmail)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.GiftCards_Activated_OrderStatusId)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDropDownListFor(model => model.GiftCards_Activated_OrderStatusId, Model.GiftCards_Activated_OrderStatuses)
                        @Html.ValidationMessageFor(model => model.GiftCards_Activated_OrderStatusId)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.SDFLabelFor(model => model.GiftCards_Deactivated_OrderStatusId)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFDropDownListFor(model => model.GiftCards_Deactivated_OrderStatusId, Model.GiftCards_Deactivated_OrderStatuses)
                        @Html.ValidationMessageFor(model => model.GiftCards_Deactivated_OrderStatusId)
                    </div>
                </div>
            </div>
        </div>
    </div>
}

@helper TabReturnRequestSettings()
{
    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <ul class="common-list">
                    <li>
                        @T("Admin.Configuration.Settings.Order.ReturnRequestsDescription1")
                    </li>
                    <li>
                        @T("Admin.Configuration.Settings.Order.ReturnRequestsDescription2")
                    </li>
                </ul>
                <div class="form-group">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.ReturnRequestsEnabled_OverrideForProject, model => model.ReturnRequestsEnabled, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.ReturnRequestsEnabled)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.ReturnRequestsEnabled)
                        @Html.ValidationMessageFor(model => model.ReturnRequestsEnabled)
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.ReturnRequestNumberMask_OverrideForProject, model => model.ReturnRequestNumberMask, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.ReturnRequestNumberMask)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.ReturnRequestNumberMask)
                        @Html.ValidationMessageFor(model => model.ReturnRequestNumberMask)
                        <ul class="common-list">
                            <li>
                                @T("Admin.Configuration.Settings.Order.ReturnRequestNumberMask.Description.ID")
                            </li>
                            <li>
                                @T("Admin.Configuration.Settings.Order.ReturnRequestNumberMask.Description.YYYY")
                            </li>
                            <li>
                                @T("Admin.Configuration.Settings.Order.ReturnRequestNumberMask.Description.YY")
                            </li>
                            <li>
                                @T("Admin.Configuration.Settings.Order.ReturnRequestNumberMask.Description.MM")
                            </li>
                            <li>
                                @T("Admin.Configuration.Settings.Order.ReturnRequestNumberMask.Description.DD")
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="form-group advanced-setting">
                    <div class="col-md-3">
                        @Html.OverrideProjectCheckboxFor(model => model.NumberOfDaysReturnRequestAvailable_OverrideForProject, model => model.NumberOfDaysReturnRequestAvailable, Model.ActiveProjectScopeConfiguration)
                        @Html.SDFLabelFor(model => model.NumberOfDaysReturnRequestAvailable)
                    </div>
                    <div class="col-md-9">
                        @Html.SDFEditorFor(model => model.NumberOfDaysReturnRequestAvailable)
                        @Html.ValidationMessageFor(model => model.NumberOfDaysReturnRequestAvailable)
                    </div>
                </div>
            </div>
        </div>
        @Html.Partial("_ReturnRequestReasons")
        @Html.Partial("_ReturnRequestActions")
    </div>
}